package com.elvin.asynctask;

import android.app.ListActivity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.ArrayAdapter;
import android.widget.ListView;

public class MainActivity extends ListActivity {
	
	private ArrayAdapter<ListCellData> adapter;
	
	@Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        
        adapter = new ArrayAdapter<ListCellData>(this, android.R.layout.simple_list_item_1);
        setListAdapter(adapter);
        
        adapter.add(new ListCellData(this, "DownLoad Image", new Intent(this, AsyncTaskActivity.class)));
        adapter.add(new ListCellData(this, "DownLoad Image With ProgressBar", new Intent(this, AsyncTaskProgressBarActivity.class)));
        adapter.add(new ListCellData(this, "DownLoad Image With Handler1", new Intent(this, AtyHandler1.class)));
        adapter.add(new ListCellData(this, "Send Message2", new Intent(this, AtyHandler2.class)));
        adapter.add(new ListCellData(this, "Send Message3", new Intent(this, AtyHandler3.class)));
        adapter.add(new ListCellData(this, "Looper", new Intent(this, AtyLooper.class)));
        adapter.add(new ListCellData(this, "Looper2", new Intent(this, AtyLooper2.class)));
        
        
        
    }
	

	 protected void onListItemClick(ListView l, View v, int position, long id) {
	    	// TODO Auto-generated method stub
	    	ListCellData data = adapter.getItem(position);
	    	data.startActivity();
	    	super.onListItemClick(l, v, position, id);
	    }

}
